import { useState, useEffect } from "react";
import { Button, Input, Space, Select, Alert, Checkbox } from "antd";
import { getAllPrinter, printReturnGoods } from "@/utils/print.jsx";
import {
	setPrinterName,
	getPrinterName,
	getCurrentUser,
	getExpressRelativePrinter,
	setExpressRelativePrinter
} from "@/utils/authority";
import { isEmpty } from "lodash";
const { Option } = Select;

const usePrint = () => {
	//打印机列表
	const [printList, setPrintList] = useState([]);
	// 下拉数据
	const printOptions =
		!isEmpty(printList) &&
		printList.map(d => (
			<Option key={d} value={d}>
				{d}
			</Option>
		));

	useEffect(() => {
		getAllPrinter(value => {
			setPrintList(value);
		});
	}, []);
	return {
		printList,
		setPrintList,
		printOptions,
		setPrinterName,
		getPrinterName,
		getCurrentUser,
		getExpressRelativePrinter,
		setExpressRelativePrinter
	};
};

export default usePrint;
